if(window.jQuery && window.jQuery.PPF && !window.jQuery.PPF.shijuanview) {
	(function($){
		$PPF.extend({
			shijuanview : {
				select:function(id){
					if(!PPF.user.islogin()){
						PPF.user.login(function(){PPF.shijuanview.select(id);});
						return;
					}
					//disable click event!
					$("#kaojuan_select").unbind('click').addClass("selecting").removeClass("toselect");
					$.post(__System.roots.exam + "select/do",{sjid:id,inajax:1},function(data){
						if(data._code != 0){
							if(data._code == -109) {
								PPF.user.login(function(){PPF.shijuanview.select(id);});
								return;
							}
							PPF.tips( {msg:PPF.jsonmsg(data,"选题失败"),timeout:1000,type:1} );
							if(typeof data._url != "undefined" && data._url){
								setTimeout(function(){location.href = data._url},3000);
							}else{
								$("#kaojuan_select").bind(
									'click',
									function(){
									PPF.shijuanview.select( $(this).attr('key') );
								}).addClass("toselect").removeClass("selecting");
							}
							return;
						}else{
							PPF.tips( {msg:PPF.jsonmsg(data,"选题成功"),timeout:1000} );
							setTimeout(function(){location.href = data._url},1000);
							//select success!
						}
					},'json');
				}
				,wait: function(t,id){
					if( t - __System.time < 1 ){
						location.href = __System.roots.exam + 'kaoshi/' + id;
						return;
					}
					$("#exam_waitto").html( PPF.timeFormate( t - __System.time ) );
					setTimeout(function(){PPF.shijuanview.wait(t,id)},499);
				}
			}
		});
	})(jQuery);
}

jQuery(function($){
	$("#kaojuan_select").bind(
		'click',
		function(){
		PPF.shijuanview.select( $(this).attr('key') );
	});
});